import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    redirect: '/index',
    component: Layout,
    hidden: true,
    children: [{
      path: 'index',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: 'Dashboard', icon: 'crm' }
    }]
  },

  {
    path: '/icon',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Icon',
        component: () => import('@/views/svg-icons/index'),
        meta: { title: 'Icon', icon: 'icon' }
      }
    ]
  },

  {
    path: '/article',
    component: Layout,
    redirect: '/article/index',
    name: 'Articles',
    meta: { title: 'Articles', icon: 'book' },
    children: [
      {
        path: 'index',
        name: 'ArticleList',
        component: () => import('@/views/user/deptUser'),
        meta: { title: 'ArticleList', icon: 'article' }
      },
      {
        path: 'articleRecycle',
        name: 'ArticleRecycle',
        component: () => import('@/views/user/deptUser'),
        meta: { title: 'ArticleRecycle', icon: 'del' }
      },
      {
        path: 'articleCate',
        name: 'ArticleCate',
        component: () => import('@/views/menu/index'),
        meta: { title: 'ArticleCate', icon: 'cate' }
      }
    ]
  },

  {
    path: '/order',
    component: Layout,
    redirect: '/order/index',
    name: 'Orders',
    meta: { title: 'Orders', icon: 'book' },
    children: [
      {
        path: 'index',
        name: 'OrdersList',
        component: () => import('@/views/user/deptUser'),
        meta: { title: 'OrdersList', icon: 'article' }
      }
    ]
  },

  {
    path: '/member',
    component: Layout,
    redirect: '/member/index',
    name: 'Member',
    meta: { title: 'Member', icon: 'peoples' },
    children: [
      {
        path: 'index',
        name: 'MemberList',
        component: () => import('@/views/user/deptUser'),
        meta: { title: 'MemberList', icon: 'userList' }
      },
      {
        path: 'memberRecycle',
        name: 'MemberRecycle',
        component: () => import('@/views/user/deptUser'),
        meta: { title: 'MemberRecycle', icon: 'del' }
      },
      {
        path: 'memberGrade',
        name: 'MemberGrade',
        component: () => import('@/views/menu/index'),
        meta: { title: 'MemberGrade', icon: 'grade' }
      }
    ]
  },

  {
    path: '/system',
    component: Layout,
    redirect: '/system/index',
    name: 'System',
    meta: { title: 'System', icon: 'system' },
    children: [
      {
        path: 'node',
        name: 'Node',
        component: () => import('@/views/node/index'),
        meta: { title: 'Node', icon: 'routers' }
      },
      {
        path: 'menu',
        name: 'Menu',
        component: () => import('@/views/menu/index'),
        meta: { title: 'Menu', icon: 'menu' }
      },
      {
        path: 'role',
        name: 'Role',
        component: () => import('@/views/role/index'),
        meta: { title: 'Role', icon: 'role' }
      },
      {
        path: 'department',
        name: 'Department',
        component: () => import('@/views/department/index'),
        meta: { title: 'Department', icon: 'department' }
      },
      {
        path: 'user',
        name: 'User',
        component: () => import('@/views/user/index'),
        meta: { title: 'User', icon: 'users' }
      },
      {
        path: 'logs',
        name: 'Logs',
        component: () => import('@/views/user/logs'),
        meta: { title: 'Logs', icon: 'users' }
      },
      {
        path: 'deptUser',
        name: 'DeptUser',
        component: () => import('@/views/user/deptUser'),
        meta: { title: 'DeptUser', icon: 'dept' }
      },
      {
        path: 'index',
        name: 'Sys',
        component: () => import('@/views/system/index'),
        meta: { title: 'Sys', icon: 'sysCogs' }
      },
      {
        path: 'fields',
        name: 'Fields',
        component: () => import('@/views/system/fields'),
        meta: { title: 'Fields', icon: 'toolSet' }
      },
      {
        path: 'modules',
        name: 'Modules',
        component: () => import('@/views/system/modules'),
        meta: { title: 'Modules', icon: 'customModule' }
      }
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

